# class Dog:
#         def __init__(self, name, gender, energy, weight):
#             self.name = name
#             self.gender = gender
#             self.energy = energy
#             self.weight = weight
#             print(f'你好，我的名字是{self.name}，我是{self.gender}，很高兴成为你的电子宠物')
#
#         def sit(self):
#             print(self.name + '正在蹲下')
#
#         def roll_over(self):
#             print(self.name + '正在打滚')
#
#         # 任务2：让电子宠物吃东西？？？(食物为汉堡包，能量增加10，体重增加5；其余则只增加能量2)
#         def eat(self, food):
#             if food == 'hamberger':
#                 self.energy += 10
#                 self.weight += 5
#                 print('汉堡包真好吃，但是别给我喂太多')
#             else:
#                 self.energy += 2
#                 print('好美味！')
#
#         # 任务3：让电子宠物显示状态
#         def display(self):
#             print(f'我当前的能量是{self.energy}，体重是{self.weight}')
#             if self.energy < 50:
#                 print('快补充能量！')
#             elif self.weight > 50:
#                 print('超重啦，快带我做运动吧！')
#             else:
#                 print('我很健康！')
#         class Dog2(Dog):
#             def __init__(self,shu1,shu2):
#                 self.shu1 = shu1
#                 self.shu2 = shu2
#             def jia(self):
#                 he=self.shu1+self.shu2
#                 print(f'俩数之和为：{he}')
#             def jian(self):
#                 cha=self.shu1-self.shu2
#                 print(f'俩数之差为：{cha}')
#             def chen(self):
#                 ji=self.shu1*self.shu2
#                 print(f'俩数之积为：{ji}')
#             def jian(self):
#                 shang=self.shu1/self.shu2
#                 print(f'俩数之差为：{shang}')



# class Tsgl:
#     def __init__(self,sname,zz,tjy,state=0):
#         self.sname=sname
#         self.zz=zz
#         self.tjy=tjy
#         self.state=state
#     def info(self):
#         print(f"书名: {self.sname}")
#         print(f"作者: {self.zz}")
#         print(f"推荐语: {self.tjy}")
#         if self.state==0:
#             print('状态：已借出')
#         else:
#              print('状态：未借出')
#
# book1 = Tsgl("666", "6", "你会变得666",0)
# book2 = Tsgl("re0", "1", "无论循环多少次，我都不会放弃你的",0)
# book3 = Tsgl("刀剑", "2", "开挂流桐姥爷",0)
# book1.info()
# book2.info()
# book3.info()
#
# class Book:
#     def __init__(self,books):
#         self.books=[]
#     def cha(self):
#         for book in self.books:
#          print(f"书籍信息：{book}")
#     def jia(self):
#         self.books.append(input('请输入要添加的书籍名称：'))
#         print(f"添加成功，当前书籍列表：{self.books}")
#     def jie(self, book_name, reader):
#         book_name=input('请输入要查找的书籍名称：')
#         for book in self.books:
#             if book.name == book_name:
#                 book.borrowed = True
#                 print(f"借阅成功")
#                 break
#         else:
#             print("未找到该书籍或书籍已被借阅。")
#
#     def huan(self):
#         bname=input('请输入要还的书的名称：')
#         for book in self.books:
#             if book.name == bname:
#                 book.borrowed = False
#                 book.reader = None
#                 print("归还成功。")
#                 break
#         else:
#             print("未找到该书籍或书籍未被借阅。")
# book=Book()
# while True:
#     print('1.查询\n2.添加\n3.借阅\n4.归还\n5.退出\n')
#     choice = int(input('请输入数字： '))
#     if choice == 1:
#         book.cha()
#     elif choice == 2:
#         book.jia()
#     elif choice == 3:
#         book.jie()
#     elif choice == 4:
#         book.huan()
#     elif choice == 5:
#         print('感谢使用')
#         break

class BookInfo:
    def __init__(self, name):
        self.name = name
        self.borrowed = False
        self.reader = None


class Book:
    def __init__(self):
        self.books = []

    def cha(self):
        for book in self.books:
            print(f"书籍信息：{book.name}, 借阅状态：{'已借阅' if book.borrowed else '未借阅'}, 借阅者：{book.reader if book.borrowed else '无'}")

    def jia(self):
        book_name = input('请输入要添加的书籍名称：')
        self.books.append(BookInfo(book_name))
        print(f"添加成功，当前书籍列表：{ self.books}")

    def jie(self):
        book_name = input('请输入要查找的书籍名称：')
        for book in self.books:
            if book.name == book_name and not book.borrowed:
                book.borrowed = True
                book.reader = input("请输入借阅者姓名：")
                print(f"借阅成功，借阅者：{book.reader}")
                break
        else:
            print("未找到该书籍或书籍已被借阅。")

    def huan(self):
        bname = input('请输入要还的书的名称：')
        for book in self.books:
            if book.name == bname and book.borrowed:
                book.borrowed = False
                book.reader = None
                print("归还成功。")
                break
        else:
            print("该书籍未被借出。")


book = Book()
while True:
    print('+--------------------------------------------+')
    print('|           -欢迎使用图书管理系统-               |')
    print('+--------------------------------------------+')
    print('|               -1.查看图书-                   |')
    print('|               -2.添加图书-                   |')
    print('|               -3.借阅图书-                   |')
    print('|               -4.归还图书-                   |')
    print('|               -5.退出系统-                   |')
    print('+--------------------------------------------+')
    choice = int(input('请输入你要进行的操作： '))
    if choice == 1:
        book.cha()
    elif choice == 2:
        book.jia()
    elif choice == 3:
        book.jie()
    elif choice == 4:
        book.huan()
    elif choice == 5:
        print('感谢使用')
        break


